package com.example.spindrift.Controllers;

import com.example.spindrift.models.SysSongListSong;
import com.example.spindrift.service.SongListSongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/SongListSong")
public class SongListSongController {
    @Autowired
    SongListSongService songListSongService;

    /**
     * 收藏一首音乐到指定歌单
     * @param songListSong 收藏信息（songId:Integer 歌曲ID，songListId:Integer 歌单ID）
     * @return
     */
    @PostMapping("/insertSongListSong")
    public Boolean insertSongListSong(@RequestBody SysSongListSong songListSong){
        return songListSongService.insertSongListSong(songListSong) > 0;
    }

    /**
     * 收藏多首歌曲到指定歌单
     * @param songListId 歌单ID
     * @param songIds 歌曲ID：id1,id2,id3
     * @return
     */
    @GetMapping("/insertSongListSongMult")
    public Boolean insertSongListSongMult(@RequestParam Integer songListId,@RequestParam String songIds){
        return songListSongService.insertSongListSongMult(songListId,songIds) > 0;
    }/**
     * 判断指定歌曲在指定的歌单中是否存在
     * @param songListId 歌单ID
     * @param songId 歌曲ID：id1,id2,id3
     * @return
     */
    @GetMapping("/getSongListSongIsExist")
    public Boolean getSongListSongIsExist(@RequestParam Integer songListId,@RequestParam Integer songId){
        return songListSongService.getSongListSongIsExist(songListId,songId) == null;
    }

    /**
     * 从指定歌单中取消收藏
     * @param songListId 歌单ID
     * @param songIds 歌曲ID集合
     * @return
     */
    @DeleteMapping("/delSongListSong")
    public Boolean delSongListSong(@RequestParam Integer songListId,@RequestParam String songIds){
        return songListSongService.delSongListSong(songListId,songIds) > 0;
    }
}
